package com.example.feign;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 使用Hystrix的FallbackFactory统一的熔断处理同时将异常处理和业务解耦
 */
@Component
public class GitHubApiClientFailBackFactory implements FallbackFactory<GitHubApiClient> {
    @Override

    public GitHubApiClient create(Throwable cause) {

        return new GitHubApiClient() {

            @Override
            //@RequestMapping(value = "/getbook", method = RequestMethod.POST)
            public String getbook( Map<String, Object> book){
                return "get boook error!";
            }

            @Override
            //@RequestMapping(value = "/myname", method = RequestMethod.POST)
            public Object myname( Map<String, Object> map)
            {
                return "factory m name error!" ;
            }



        };

    }
}
